package com.itheima.chapter08.set.map;

import java.util.HashMap;
import java.util.Map;

//Map基本使用
public class Mapdemo1 {
    public static void main(String[] args) {
        Map<String,String> map =new HashMap<>();
        map.put("张无忌","赵敏");
        map.put("郭靖","黄蓉");
        map.put("杨过","小龙女");
        map.put("钱钱","太子");
        method1(map);
        System.out.println("------------------");
        //nethod2(map);
        method3(map);
        System.out.println("------------------");
        method4(map);
        System.out.println("------------------");
        method5(map);
        System.out.println("------------------");
        method6(map);
    }

    private static void method6(Map<String, String> map) {
        int size = map.size();
        System.out.println(size);
    }

    private static void method5(Map<String, String> map) {
        boolean empty = map.isEmpty();
        System.out.println(empty);
    }

    private static void method4(Map<String, String> map) {
        //判断集合中是否包含指定的值
        boolean b1 = map.containsValue("小龙女");
        System.out.println(b1);
        boolean b2 = map.containsValue("拉拉");
        System.out.println(b2);
    }

    private static void method3(Map<String, String> map) {
        //判断集合中是否包含指定的键
        boolean b1 = map.containsKey("郭靖");
        System.out.println(b1);
        boolean b2 = map.containsKey("果果");
        System.out.println(b2);
    }

    private static void nethod2(Map<String, String> map) {
        //清除
        map.clear();
        System.out.println(map);
    }

    private static void method1(Map<String, String> map) {
        //根据键删除键值对元素
        String remove = map.remove("郭靖");
        System.out.println(remove);
        String remove1 = map.remove("果果");
        System.out.println(remove1);
    }
}
